<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">班级通知添加(APP消息)</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="通知主题" style="margin-bottom: 0px;">
              <el-input v-model="vbt" class="select-block"  icon="add" ></el-input>
				<!--<el-select v-model="vbt" class="select-block">
				<el-option :label="v.mc" :value="v.mc" v-for="v in tzboxlist"></el-option>
			    </el-select>-->
			</el-form-item>
			
            <el-form-item label="预计发送时间">
            	<el-date-picker  v-model="vbtime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" class="select-block"> </el-date-picker>
			</el-form-item>
			<el-form-item label="消息类型">
				<el-select v-model="vxxlx" clearable class="select-block">
                    <el-option label="强制阅读" value="Y"></el-option>
                    <el-option label="普通消息" value="N"></el-option>
                </el-select>
			</el-form-item>
			<el-form-item label="通知内容">
				 <el-input v-model="vnr" type="textarea" :rows="4" placeholder="请输入通知内容" icon="add" class="select-block"></el-input>
			</el-form-item>
		</el-form>
		<el-button type="primary" class="submit" @click="submit">发送</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				vbt: '',
				vnr: '',
				vxxlx:'N',
				vbtime:'',
                vfslx:'',
                vlsid:'',
				vnoticesource: '',
				vbjid:'',
				vxh: '',
				vbjid1:[],
				dialogTableVisible: true,
				 tzboxlist:[]
			}
		},
		created () {
			this.vbjid=this.params;
			//	this.gettzcomlist();
		},
		methods: {
			
			submit() {
			    this.$store.state.loading = true;
//				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
			    if(!this.vbt) {
					this.$message.warning('请填写主题');
					this.$store.state.loading = false;
					return;
				} 
				else if(!this.vnr){
					this.$message.warning('请填写主题内容');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vbtime){
					this.$message.warning('请选择发送时间');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					bt: this.vbt+'',
					nr: this.vnr+'',
					fslx:'bj',
					isqz:this.vxxlx,
					noticesource:'B'+'',
					bjid: this.vbjid+'',
					yjfssj:this.vbtime,
					yhid: logininfo.id+'',
					xxid:logininfo.xxid+''
				});
				this.axios.post(this.$store.state.api + 'notice/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
						    this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
        gettzcomlist(){
        	 var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      yhid:logininfo.id+'',
                      xxid:logininfo.xxid+''
               })
                 this.axios.post(this.$store.state.api + 'bq/gettzzt',  params2 )
                 .then(res => {
               let data = res.data.data;
                  let list = data.list;
                  this.tzboxlist = list;
                 }).catch(res => {
				})				
        },
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
.wrap {
	text-align: center;
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}

.select-block {
	display: block;
	width: 85%;
}

.submit {
	width: 120px;
}
.weekdiv{
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;


			}
			.wdiv0 {
				width: 90px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 40px;
				height: 200px;
				float: left;
				background: lightgoldenrodyellow;
			}
</style>
